import 'package:flutter/material.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:xinxuan/common/appbar_util.dart';
import 'package:xinxuan/common/my_underline_tab_indicator.dart';
import 'package:xinxuan/common/seckill_recovery_good_arr.dart';
import 'package:xinxuan/controllers/recovery_controller/recovery_page_controller.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:xinxuan/utils/color_util.dart';

class RecoveryPage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return GetBuilder<RecoveryPageController>(
      init: RecoveryPageController(),
      builder: (controller) {
        return Scaffold(
          backgroundColor: pageBgColor,
          appBar: AppBarUtil(
            title: '回收列表',
            backgroundColor: pageBgColor,
          ),
          body: DefaultTabController(
            length: 2, 
            initialIndex: controller.tabIndex.value,
            child: Column(
              children: [
                Container(
                  constraints: BoxConstraints(maxHeight: 44.h),
                  child: Material(
                    color: bgWhiteColor,
                    child: TabBar(                
                      indicator: MyUnderlineTabIndicator(
                        wantWidth: 20.w,
                        borderSide: BorderSide(
                          width: 5.h,
                          color: bgMainColor
                        )
                      ),
                      indicatorColor: bgMainColor,
                      labelColor: mainTextColor,
                      unselectedLabelColor: textSubtitleColor,
                      labelStyle: TextStyle(
                        fontSize: 14.sp
                      ),
                      unselectedLabelStyle: TextStyle(
                        fontSize: 14.sp
                      ),
                      onTap: (index) {
                        controller.tabIndex.value = index;
                      },
                      tabs: [
                        Tab(text: '上次记录'),
                        Tab(text: '本次记录')
                      ]
                    ),
                  ),
                ),
                Expanded(child: TabBarView(
                  children: controller.dataArr.map((item) {
                    return SeckillRecoveryGoodArr(seckillRecoveryItems: item.data!, recoveryPageController: controller);
                  }).toList(),
                ))
              ],
            )
          ),
        );
      },
    );
  }
}